
#include <cstdio>
#include <conio.h> // 出错，功能暂未实现
#include <string>
using namespace std;

struct Scale   	/* 记录每个人各科成绩 */
{
    char name[10];
    int chi_sco;
    int eng_sco;
    int math_sco;
};

struct     		/* 记录各科总分 */
{
    int chi;
    int eng;
    int math;
}Sum={0,0,0};	/* 全局，可省略初值0 */

/* 记录chi,eng,math最高分 */
struct
{
    int max_chi;		/* 最高分数 */
    int max_eng;
    int max_math;
    char name_chi[10];	/* 最高分者的姓名 */
    char name_eng[10];
    char name_math[10];
}TopGuy;

int main() {
    struct Scale student[50];	/* 定义结构数组 */
    int count=0;
    char reTry='y';

    do {
        printf("\n请输入学生姓名：");
        scanf("%s",student[count].name);
        printf("请输入语文成绩：");
        scanf("%d",&student[count].chi_sco);
        printf("请输入英文成绩：");
        scanf("%d",&student[count].eng_sco);
        printf("请输入数学成绩：");
        scanf("%d",&student[count].math_sco);

        Sum.chi += student[count].chi_sco;	/* 各科计分 */
        Sum.eng += student[count].eng_sco;
        Sum.math += student[count].math_sco;

        if(student[count].chi_sco > TopGuy.max_chi)
        {
            TopGuy.max_chi = student[count].chi_sco;
            strcpy(TopGuy.name_chi,student[count].name);
        }
        if(student[count].eng_sco > TopGuy.max_eng)
        {
            TopGuy.max_eng = student[count].eng_sco;
            strcpy(TopGuy.name_eng,student[count].name);
        }
        if(student[count].math_sco > TopGuy.max_math)
        {
            TopGuy.max_math = student[count].math_sco;
            strcpy(TopGuy.name_math,student[count].name);
        }
        printf("是否继续输入?(请输入Y/N或y/n)");
        do
        {
            reTry = getche();
        }while((reTry!='Y')&&(reTry!='y')&&(reTry!='N')&&(reTry!='n'));

        count++;
    }while((reTry=='y')||(reTry=='Y'));

    if(count>0) {
        printf("共输入%d人\n",count);
        printf("语文平均%5.2f分，最高分%d分：%s\n", \
        ((float)Sum.chi/(float)count), \
        TopGuy.max_chi,TopGuy.name_chi);
        printf("英文平均%5.2f分，最高分%d分：%s\n", \
        ((float)Sum.eng/(float)count), \
        TopGuy.max_eng,TopGuy.name_eng);
        printf("数学平均%5.2f分，最高分%d分：%s\n", \
        ((float)Sum.math/(float)count), \
        TopGuy.max_math,TopGuy.name_math);
    }

//    getche();
    return 0;
}

